# +--------------------------
# | User: zq                -
# | Version: python3.7      -
# | Time: 2020-03-14 10:51                
# +--------------------------
import time
from selenium import webdriver
from scrapy import Selector
from selenium.common.exceptions import NoSuchElementException

# 使用 webdriver
chrome_browser = webdriver.Chrome(
    executable_path="/Users/zhangqiang/Desktop/05-python/03-spider-learn/spider/csdn_spider/chromedriver")
chrome_browser.get("https://item.jd.com/11410079235.html#comment")

try:
    click_ele = chrome_browser.find_element_by_xpath("//li[@clstag='shangpin|keycount|product|shangpinpingjia_2']")
    click_ele.click()
except NoSuchElementException as e:
    pass

sel = Selector(text=chrome_browser.page_source)
print(sel.xpath("//span[@class='price J-p-11410079235']/text()").extract_first())

# 关闭浏览器
chrome_browser.close()
